<template>
  <Field
    :border="border"
    :name="name"
    :label="label"
    :labelWidth="labelWidth"
    :disabled="disabled"
    :placeholder="placeholder"
    :type="type"
    :rules="rules"
  >
    <template #input>
      <van-rate
        v-model="currentValue"
        @change="$emit('change', currentValue, name)"
        :readonly="showType === 'view'"
        :allow-half="allowHalf"
        :count="count"
      />
    </template>
  </Field>
</template>

<script>
import common from './item'
import { Rate } from 'vant'
export default {
  mixins: [common],
  components: {
    vanRate: Rate
  },
  computed: {
    // 自定义星级数量（currentValue可以是半星：0.5）
    count () {
      let o = this.info
      return o.count || 5
    },
    allowHalf () {
      let o = this.info
      return o.allowHalf || true
    }
  }
}
</script>
